package bishi;

import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int sum = 0;
        int min = 0;
        int max = 0;
        int x = 0;
        int y = 0;
        for(int i=0;i<n;i++){
            x = in.nextInt();
            y = in.nextInt();
            min = x < y ? x : y;
            max = x > y ? x : y;
            if(max <= m){
                sum += min;
            }else{
                sum += max;
            }
        }
        System.out.println(sum);
    }
}
